package com.codeoss.framework.view.parser;

import org.springframework.stereotype.Service;

import com.codeoss.framework.expression.Expression;
import com.codeoss.framework.expression.ExpressionUtil;
import com.codeoss.framework.util.StringUtils;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.TabPage;
import com.fasterxml.jackson.databind.node.ObjectNode;

@Service("tabpageParser")
public class TabPageParser extends AbstractComponentParser {
	protected void setAttributes(IParseContext parseContext, ObjectNode objectNode, Component component) {
		super.setAttributes(parseContext, objectNode, component);
		TabPage tabPage = (TabPage) component;
		String labelExpression = objectNode.get("labelExpression").asText();
		if (!StringUtils.isEmpty(labelExpression)) {
			Expression expression = ExpressionUtil.convertLabelToExpression(labelExpression,Expression.EXPRESSION_TYPE_JAVASCRIPT);
			tabPage.setLabelExpression(expression);
		}
	}

	@Override
	protected Component createComponent(IParseContext parseContext, ObjectNode objectNode) {
		// TODO Auto-generated method stub
		return new TabPage();
	}

}
